package com.hspedu.homework.homework02;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/3/23
 * @time 19:14
 */
public class Homework02 {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, IOException {
        Class<File> fileClass = File.class;
        Constructor<?>[] declaredConstructors = fileClass.getDeclaredConstructors();
        for (Constructor<?> declaredConstructor : declaredConstructors) {
            System.out.println(declaredConstructor);
        }
        Constructor<File> constructor = fileClass.getConstructor(String.class);
        File file = constructor.newInstance("D:\\BaiduNetdiskDownload\\韩顺平2021基础学Java\\mytemp\\mynew.txt");
        Method method = fileClass.getMethod("createNewFile");
        method.invoke(file);
    }
}
